package com.logicalthinking.socialmall.service.impl;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.PropertyCheckUtil;
import com.github.chenlijia1111.utils.list.Lists;
import com.logicalthinking.socialmall.dao.OrderAppendMapper;
import com.logicalthinking.socialmall.entity.OrderAppend;
import com.logicalthinking.socialmall.service.OrderAppendServiceI;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单补充参数
 *
 * @author chenLiJia
 * @since 2020-02-19 16:12:21
 **/
@Service
public class OrderAppendServiceImpl implements OrderAppendServiceI {


    @Resource
    private OrderAppendMapper orderAppendMapper;


    /**
     * 添加
     *
     * @param params 添加参数
     * @return com.github.chenlijia1111.utils.common.Result
     * @author chenLiJia
     * @since 2020-02-19 16:12:21
     **/
    @Override
    public Result add(OrderAppend params) {

        int i = orderAppendMapper.insertSelective(params);
        return i > 0 ? Result.success("操作成功") : Result.failure("操作失败");
    }

    /**
     * 编辑
     *
     * @param params 编辑参数
     * @return com.github.chenlijia1111.utils.common.Result
     * @author chenLiJia
     * @since 2020-02-19 16:12:21
     **/
    @Override
    public Result update(OrderAppend params) {

        int i = orderAppendMapper.updateByPrimaryKeySelective(params);
        return i > 0 ? Result.success("操作成功") : Result.failure("操作失败");
    }

    /**
     * 批量添加
     *
     * @param list
     * @return
     */
    @Override
    public Result batchAdd(List<OrderAppend> list) {
        if (Lists.isNotEmpty(list)) {
            orderAppendMapper.batchAdd(list);
        }
        return Result.success("操作成功");
    }

    /**
     * 条件查询
     *
     * @param condition
     * @return
     * @author chenLiJia
     * @since 2020-02-19 16:12:21
     **/
    @Override
    public List<OrderAppend> listByCondition(OrderAppend condition) {

        PropertyCheckUtil.transferObjectNotNull(condition, true);
        return orderAppendMapper.select(condition);
    }


}
